import Vue from 'vue';
import routes from './routes'; 
import './css/public.css';
import './css/weui.css';

window.app = new Vue({
  el: '#app', 
  data: {
    currentRoute: window.location.pathname
  },
  computed: {
    ViewComponent () { 
      const matchingView = routes[this.currentRoute.split("?")[0]]  
      return matchingView
        ? require('./pages/' + matchingView + '.vue')
        : require('./pages/404.vue')
    }
  },
  render (h) { 
    return h(this.ViewComponent)
  }
})

window.addEventListener('popstate', () => { 
  app.currentRoute = window.location.pathname
})

 document.addEventListener("DOMContentLoaded", function () {
          window.history.pushState(
            null,
            'Board',
            '/board'
          );
          app.currentRoute = '/board';
 }, false);